from lib.ZAnimation import ZAnimation
from lib.ZButton import ZButton
from lib.ZImage import ZImage
from lib.ZNode import ZNode
from lib.res.fun import _create_image_alpha
from lib.res.glo import SRC


class Close ( ZButton ) :
	def __init__ ( self , father ) :
		image = _create_image_alpha ( SRC [ 'button' ] [ 'close' ] [ 'default' ] )
		over = _create_image_alpha ( SRC [ 'button' ] [ 'close' ] [ 'over' ] )
		super ( Close , self ).__init__ ( father , image , over , [ 24 , 24 ] )
		self._pos = self.father._size [ 0 ] - 24 , 0

	def _action ( self ) :
		from lib.ZScreen import scenes
		scenes.remove ( self.father )
		for x in scenes :
			x._running = True


class ZPanel ( ZNode ) :
	def __init__ ( self , father , background_url , size ) :
		super ( ZPanel , self ).__init__ ( father )
		self._add ( ZImage ( self , background_url , size , True ) )
		self._add ( Close ( self ) )
